Public Member Functions | |
Signature () | |
void | setValues (AccessibleObject c) |
String | getAnnotations () |
String | getExceptions () |
String | getModifiers () |
String | getName () |
String | getParameters () |
int | getType () |
String | getParameterNames () |
String | getReturnType () |
String | getUcfirstName () |
Package Attributes | |
String | annotations |
String | modifiers |
String | name |
String | ucfirstName |
String | parameters |
String | parameterNames |
String | exceptions |
String | returnType |
Integer | type |
Private Member Functions | |
String | stripTrailingClass (String s) |
Definition at line 26 of file Signature.java.
jvn.Signature.Signature | ( | ) |
void jvn.Signature.setValues | ( | AccessibleObject | c | ) |
If we were not using an AccessibleObject parameter, we'd have to duplicate the code in two methods.
c | the constructor or method we want to turn into strings. |
Definition at line 47 of file Signature.java.
References jvn.Signature.annotations, jvn.Signature.exceptions, jvn.Signature.getModifiers(), jvn.Signature.modifiers, jvn.Signature.name, jvn.Signature.parameterNames, jvn.Signature.parameters, jvn.Signature.returnType, jvn.Signature.stripTrailingClass(), jvn.Signature.type, and jvn.Signature.ucfirstName.
Referenced by jvn.JvnWrapperCreator.generateOneFile().
00047 { 00048 00049 Type [] parms = null; 00050 Type [] excepts = null; 00051 Annotation [] annots = null; 00052 Annotation [][] parmAnnots = null; 00053 String [] strings = null; 00054 00055 String dummy = null; 00056 String dummy2 = null; 00057 00058 00059 if (c instanceof Constructor) { 00060 type = 1; // Constructor; 00061 parms = ((Constructor)c).getGenericParameterTypes(); 00062 excepts = ((Constructor)c).getGenericExceptionTypes(); 00063 annots = ((Constructor)c).getAnnotations(); 00064 parmAnnots = ((Constructor)c).getParameterAnnotations(); 00065 modifiers = Modifier.toString(((Constructor)c).getModifiers()); 00066 name = ((Constructor)c).getName(); 00067 returnType = ""; 00068 } 00069 else if (c instanceof Method) { 00070 Class<?> classReturnType = ((Method)c).getReturnType(); 00071 00072 type = 2; 00073 parms = ((Method)c).getGenericParameterTypes(); 00074 excepts = ((Method)c).getGenericExceptionTypes(); 00075 annots = ((Method)c).getAnnotations(); 00076 parmAnnots = ((Method)c).getParameterAnnotations(); 00077 modifiers = Modifier.toString(((Method)c).getModifiers()); 00078 name = ((Method)c).getName(); 00079 returnType = classReturnType.getName(); 00080 } 00081 else { 00082 System.err.println("Wrong object type passed to Signature.setValues !"); 00083 System.exit(1); 00084 } 00085 00086 00087 annotations = new String(""); 00088 if (annots != null) { 00089 for (Annotation a : annots) { 00090 String annot = a.toString(); 00091 annotations = annotations + annot + " "; 00092 if (annot.equals("@jvn.JvnRead()")) { 00093 type = 3; // @JvnRead method 00094 } 00095 else if (annot.equals("@jvn.JvnWrite()")) { 00096 type = 4; // @JvnWrite method 00097 } 00098 } 00099 } 00100 if (annotations.equals("")) { 00101 annotations = null; 00102 } 00103 00104 00105 if (modifiers.equals("")) { 00106 modifiers = null; 00107 } 00108 00109 00110 if (returnType.equals("")) { 00111 returnType = null; 00112 } 00113 00114 00115 if (name.equals("")) { 00116 System.err.println("Constructor/method name is empty ?!"); 00117 System.exit(1); 00118 } 00119 00120 // Class name is the last part of the whole class name. Straightforward. 00121 strings = name.split("\\."); 00122 name = strings[strings.length - 1]; 00123 // Put the first letter in uppercase. Not so straightforward... 00124 dummy = name.substring(1); 00125 dummy2 = name.substring(0,1).toUpperCase(); 00126 ucfirstName = dummy2.concat(dummy); 00127 00128 00129 // TODO FIXME: handle "public Foo(java.lang.Serializable o)" 00130 // Don't have an clue on how to solve the problem for now. 00131 parameters = new String(""); 00132 parameterNames = new String(""); 00133 //parameterTypes = new String(""); 00134 00135 if (parms != null) { 00136 for (int i = 0; i < parms.length; i++) { 00137 Annotation [] aArray = (parmAnnots != null)?parmAnnots[i]:null; 00138 00139 // Don't add "," if it's the last parameter. 00140 String tempParmName = "param" + i + ((i == parms.length - 1)?"":", "); 00141 String tempParmType = parms[i].toString(); 00142 String tempParmAnnot = new String(""); 00143 00144 if (aArray != null) { 00145 for (Annotation a : aArray) { 00146 tempParmAnnot = tempParmAnnot.concat(a.toString()).concat(" "); 00147 } 00148 } 00149 00150 // Strip the "class " in front of tempParmType; 00151 tempParmType = stripTrailingClass(tempParmType); 00152 00153 parameters = parameters.concat(tempParmAnnot).concat(tempParmType).concat(" ").concat(tempParmName); 00154 parameterNames = parameterNames.concat(tempParmName); 00155 } 00156 } 00157 00158 00159 exceptions = new String(""); 00160 if (excepts != null) { 00161 for (Type e : excepts) { 00162 String s = e.toString(); 00163 s = stripTrailingClass(s); 00164 00165 exceptions = exceptions + s + ", "; 00166 } 00167 } 00168 // Add JvnException to list of exceptions. 00169 exceptions = exceptions + "jvn.JvnException"; 00170 // Shouldn't happen... 00171 /*if (exceptions.equals("")) { 00172 exceptions = null; 00173 }*/ 00174 00175 }
String jvn.Signature.stripTrailingClass | ( | String | s | ) | [private] |
Strip "class " in front of the result of toString();
s | the string to modify |
Definition at line 185 of file Signature.java.
Referenced by jvn.Signature.setValues().
00185 { 00186 String result = s; 00187 Pattern p = Pattern.compile("^(class\\s)(([A-Za-z][A-Za-z0-9.]*)+)$"); 00188 Matcher matcher = p.matcher(s); 00189 if (matcher.matches()) { 00190 result = matcher.group(2); 00191 } 00192 else { 00193 // Do nothing. 00194 } 00195 return result; 00196 }
String jvn.Signature.getAnnotations | ( | ) |
Getter used by the Velocity Template
Definition at line 202 of file Signature.java.
References jvn.Signature.annotations.
00202 { 00203 //System.out.println("OUAH" + annotations); 00204 return annotations; 00205 }
String jvn.Signature.getExceptions | ( | ) |
Getter used by the Velocity Template
Definition at line 211 of file Signature.java.
References jvn.Signature.exceptions.
00211 { 00212 return exceptions; 00213 }
String jvn.Signature.getModifiers | ( | ) |
Getter used by the Velocity Template
Definition at line 219 of file Signature.java.
References jvn.Signature.modifiers.
Referenced by jvn.Signature.setValues().
00219 { 00220 return modifiers; 00221 }
String jvn.Signature.getName | ( | ) |
Getter used by the Velocity Template
Definition at line 227 of file Signature.java.
References jvn.Signature.name.
00227 { 00228 return name; 00229 }
String jvn.Signature.getParameters | ( | ) |
Getter used by the Velocity Template
Definition at line 235 of file Signature.java.
References jvn.Signature.parameters.
00235 { 00236 return parameters; 00237 }
int jvn.Signature.getType | ( | ) |
Getter used by the Velocity Template
Definition at line 243 of file Signature.java.
References jvn.Signature.type.
00243 { 00244 return type; 00245 }
String jvn.Signature.getParameterNames | ( | ) |
Getter used by the Velocity Template
Definition at line 251 of file Signature.java.
References jvn.Signature.parameterNames.
00251 { 00252 return parameterNames; 00253 }
String jvn.Signature.getReturnType | ( | ) |
Getter used by the Velocity Template
the return type of the current method.
Definition at line 267 of file Signature.java.
References jvn.Signature.returnType.
00267 { 00268 return returnType; 00269 }
String jvn.Signature.getUcfirstName | ( | ) |
Getter used by the Velocity Template
Definition at line 275 of file Signature.java.
References jvn.Signature.ucfirstName.
00275 { 00276 return ucfirstName; 00277 }
String jvn.Signature.annotations [package] |
Definition at line 28 of file Signature.java.
Referenced by jvn.Signature.getAnnotations(), and jvn.Signature.setValues().
String jvn.Signature.modifiers [package] |
Definition at line 29 of file Signature.java.
Referenced by jvn.Signature.getModifiers(), and jvn.Signature.setValues().
String jvn.Signature.name [package] |
Definition at line 30 of file Signature.java.
Referenced by jvn.Signature.getName(), and jvn.Signature.setValues().
String jvn.Signature.ucfirstName [package] |
Definition at line 31 of file Signature.java.
Referenced by jvn.Signature.getUcfirstName(), and jvn.Signature.setValues().
String jvn.Signature.parameters [package] |
Definition at line 32 of file Signature.java.
Referenced by jvn.Signature.getParameters(), and jvn.Signature.setValues().
String jvn.Signature.parameterNames [package] |
Definition at line 34 of file Signature.java.
Referenced by jvn.Signature.getParameterNames(), and jvn.Signature.setValues().
String jvn.Signature.exceptions [package] |
Definition at line 35 of file Signature.java.
Referenced by jvn.Signature.getExceptions(), and jvn.Signature.setValues().
String jvn.Signature.returnType [package] |
Definition at line 36 of file Signature.java.
Referenced by jvn.Signature.getReturnType(), and jvn.Signature.setValues().
Integer jvn.Signature.type [package] |
Definition at line 37 of file Signature.java.
Referenced by jvn.Signature.getType(), and jvn.Signature.setValues().